home *** CD-ROM | disk | FTP | other *** search
/ Plug-In Power Pack for Netscape Communicator / Plug-In Power Pack for Netscape Communicator.iso / plugins / dataviews / dvdraw / examples / testwin / exampletestwin.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-07  |  3.4 KB  |  125 lines

  1. // ExampleTestWin.cpp : Defines the initialization routines for the DLL.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <afxdllx.h>
  6. #include "TestWin.h"
  7. #include "TestDlg.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15.  
  16. static AFX_EXTENSION_MODULE ExampleTestWinDLL = { NULL, NULL };
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. //
  20. class CExampleTestWin : public CTestWinDll
  21. {
  22. public:
  23.   CExampleTestWin() {}
  24.   ~CExampleTestWin() {}
  25.  
  26.     void Release();
  27.     int    DvTestWin(VIEW view, RECTANGLE *wvp, char *clut, CFrameWnd *parent);
  28.     void GetIdInfo(CString& mfgName, CString& objName, CString& versionStr);
  29. };
  30.  
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. //
  34. int CExampleTestWin::DvTestWin(VIEW view, RECTANGLE *wvp, char *clut, CFrameWnd *parent)
  35. {
  36.   // Make sure the application's default resources are loaded from this DLL...
  37.   HINSTANCE hInstResourceClient = AfxGetResourceHandle();
  38.   AfxSetResourceHandle(ExampleTestWinDLL.hModule);
  39.  
  40.   CTestDlg testDlg(view,wvp,clut,parent);
  41.   int dlg_return = testDlg.DoModal();
  42.  
  43.   // Reset the application's default resources back to where they were...
  44.   AfxSetResourceHandle(hInstResourceClient);
  45.  
  46.   return dlg_return;
  47. }
  48.  
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. //
  52. void CExampleTestWin::Release()
  53. {
  54.     delete this;
  55. }
  56.  
  57.  
  58. /////////////////////////////////////////////////////////////////////////////
  59. //
  60. void CExampleTestWin::GetIdInfo(CString& mfgName, CString& objName, CString& versionStr)
  61. {
  62.     mfgName    = "DataViews Corporation";
  63.     objName    = "Example Test Window";
  64.   versionStr = "1.0.0.1";
  65. }
  66.  
  67.  
  68.  
  69. /////////////////////////////////////////////////////////////////////////////
  70. //
  71. extern "C" {
  72.  
  73.  
  74. /////////////////////////////////////////////////////////////////////////////
  75. //
  76. DLLEXPORT BOOL
  77. GetInterface(int idd, void **pInterf)
  78. {
  79.     *pInterf = 0;
  80.     if (idd == IID_Run) 
  81.         *pInterf = new CExampleTestWin;
  82.     return (pInterf) ? TRUE : FALSE;
  83. }
  84.  
  85.  
  86. /////////////////////////////////////////////////////////////////////////////
  87. //
  88. int APIENTRY
  89. DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  90. {
  91.     // Remove this if you use lpReserved
  92.     UNREFERENCED_PARAMETER(lpReserved);
  93.  
  94.     if (dwReason == DLL_PROCESS_ATTACH)
  95.     {
  96.         TRACE0("EXAMPLETESTWIN.DLL Initializing!\n");
  97.         
  98.         // Extension DLL one-time initialization
  99.         if (!AfxInitExtensionModule(ExampleTestWinDLL, hInstance))
  100.             return 0;
  101.  
  102.         // Insert this DLL into the resource chain
  103.         // NOTE: If this Extension DLL is being implicitly linked to by
  104.         //  an MFC Regular DLL (such as an ActiveX Control)
  105.         //  instead of an MFC application, then you will want to
  106.         //  remove this line from DllMain and put it in a separate
  107.         //  function exported from this Extension DLL.  The Regular DLL
  108.         //  that uses this Extension DLL should then explicitly call that
  109.         //  function to initialize this Extension DLL.  Otherwise,
  110.         //  the CDynLinkLibrary object will not be attached to the
  111.         //  Regular DLL's resource chain, and serious problems will
  112.         //  result.
  113.  
  114.         new CDynLinkLibrary(ExampleTestWinDLL);
  115.     }
  116.     else if (dwReason == DLL_PROCESS_DETACH)
  117.     {
  118.         TRACE0("EXAMPLETESTWIN.DLL Terminating!\n");
  119.         // Terminate the library before destructors are called
  120.         AfxTermExtensionModule(ExampleTestWinDLL);
  121.     }
  122.     return 1;   // ok
  123. }
  124.  
  125. } // extern "C"